home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Taifun / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).zip / Taifun 099 (1989-05-15)(Ossowski, Stefan)(DE)(PD).adf / PCQ / Examples / Typer.p < prev    next >
Text File  |  1989-03-31  |  1KB  |  61 lines

  1. Program Typer;
  2.  
  3. {
  4.     Instead of using the AmigaDOS routines, I'm going to just
  5.     use the Pascal routines.  This is supposed to be for
  6.     demonstration, after all, not efficiency.  Link this with
  7.  
  8.         Blink Typer.o small.lib to Typer library pcq.lib
  9. }
  10.  
  11. var
  12.     Infile : Text;
  13.  
  14.  
  15. Function GetFileName(index : Integer): String;
  16.  
  17.       {
  18.     This function requires that each file name in the command
  19.     line have at least one character of disposable delimeter
  20.     after it.  It starts looking from index, and returns a
  21.     pointer into the command line.  Index ends up as the next
  22.     unused character.
  23.       }
  24.  
  25. var
  26.    name : String;
  27. begin
  28.     while ((CommandLine[index] = ' ') or (CommandLine[index] = chr(9))) and
  29.     (index < 128) do
  30.     index := index + 1;
  31.     if index >= 128 then begin
  32.     writeln('Bad file name.');
  33.     exit(20);
  34.     end;
  35.     name := String(adr(CommandLine[index]));
  36.     while (ord(CommandLine[index]) > ord(' ')) and
  37.       (ord(CommandLine[index]) < 128) and
  38.     (index < 128) do
  39.     index := index + 1;
  40.     if index >= 128 then begin
  41.     writeln('Bad file name.');
  42.     exit(20);
  43.     end;
  44.     CommandLine[index] := chr(0);
  45.     index := index + 1;
  46.     GetFileName := name;
  47. end;
  48.  
  49. begin
  50.     if reopen(GetFileName(1), Infile) then begin
  51.     while not eof(Infile) do begin
  52.         write(Infile^);
  53.         get(Infile);
  54.     end;
  55.     close(Infile);
  56.     end else
  57.     writeln('Could not open the input file.');
  58. end.
  59.  
  60.  
  61.